/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package symulacja;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;

/**
 *
 * @author admin
 */
     class Kondensator extends JButton implements  ActionListener, MouseListener
    {
        
        public Kondensator()
        {         
            this.setBackground(Color.white);
      //      this.setBackground(Color.red);  
            this.setBounds(380, 265, 40, 27);
            this.setBorder(null);
            this.addMouseListener(this);
            this.addActionListener(this);
          
           
        }
       
        
        @Override
        public void mouseClicked(MouseEvent e) {
           
        }

        @Override
        public void mousePressed(MouseEvent e) {
            
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            
        }

        @Override
        public void mouseEntered(MouseEvent e) {
            System.out.println("Najeches na kondestator");
            kolor=Color.RED;
            aktualizuj();
        }
        
        @Override
        public void mouseExited(MouseEvent e) {
            System.out.println("Zjechales z kondesatora na kondestator");
            kolor=Color.BLACK;
            aktualizuj();
        }
        
        
        

        @Override
        public void actionPerformed(ActionEvent e) {
            System.out.println("Nacisnoles kondesator");
        }
        
        public void aktualizuj()
        {
            this.paint(this.getGraphics());
        }   
        
        @Override
        public void paintComponent(Graphics g)
        {
             // Wymiary kondenstatora (380, 265, 40, 27);
            if(Symulacja.rysowanie.flaga)
            {
                super.paintComponent(g);
                g.setColor(Color.GREEN);
                g.drawLine(20, 0, 20, 5);
                g.setColor(kolor);
                g.drawLine(0, 5, 40, 5);//kondensator gorna okladka
            //    g.drawString("C=", 70, 20);
                g.drawLine(0, 20, 40, 20);//koniec kondensatora dolna okladka
                g.setColor(Color.GREEN);
                g.drawLine(20, 20, 20,27 );
            }
        }
        
        private Color kolor=Color.BLACK;

        

        
        
    }//koniec klasy prywatnej kondensator